#version 110


struct Light
{
  vec4 position;
  vec4 ambient;
  vec4 diffuse;
  vec4 specular;
  vec3 attenuation;
};

struct Material
{
  vec4  ambient;
  vec4  diffuse;
  vec4  specular;
  float shininess;
  vec4  emission;
};


vec4 calculate_phong_lighting (
                                mat4      mat_world,
                                mat4      mat_view,
                                vec4      lVertex,
                                vec3      lNormal,
                                Light     light,
                                Material  mat
                                );


uniform mat4 mat_view;
uniform mat4 mat_world;

uniform Light light;
uniform Material mat;

uniform sampler2D diffuse;


varying vec4 lVertex;
varying vec3 lNormal;
varying vec2 fTexCoord0;
                            

void main ()
{

  vec4 color = calculate_phong_lighting (mat_world, mat_view, lVertex, lNormal, light, mat);
  
  gl_FragColor = texture2D(diffuse, fTexCoord0) * color;
}

